﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CommonLibrary;

namespace GUI
{	
	/// <summary>
	/// Form that takes application credentials.
	/// </summary>
	public partial class ApplicationLogin : Form
	{
		#region Constructors
		/// <summary>
		/// Default constructor.
		/// </summary>
		public ApplicationLogin()
		{
			InitializeComponent();
		}
		#endregion Constructors

		#region Button click Handlers
		/// <summary>
		/// Handles Exit button click event.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void btnExit_Click(object sender, EventArgs e)
		{
			this.Close();
		}
		/// <summary>
		/// Opens main window.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void btnOk_Click(object sender, EventArgs e)
		{
			this.Hide();
			MainWindow mainWindow = new MainWindow(
				this.mtbAppId.Text.StringToSecureString(),
				this.mtbAppSecret.Text.StringToSecureString());
			mainWindow.programClosingEvt += new ProgramClosingDelegate(MainWindow_programClosingEvt);
			mainWindow.Show();
		}
		#endregion Button click Handlers

		#region Private methods
		/// <summary>
		/// Closes application login window.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="args"></param>
		private void MainWindow_programClosingEvt(object sender, EventArgs args)
		{
			this.Close();
		}
		#endregion Private methods
	}
}
